
//����������
package com.creawor.hz_market.t_balance_office;
import java.util.Iterator;
import java.util.List;

import org.apache.log4j.Logger;

import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Query;

import com.creawor.hz_market.servlet.LoadMapInfoAjax;
import com.creawor.imei.base.AbsQueryMap;

public class t_balance_office_QueryMap extends AbsQueryMap {
	private static final Logger logger = Logger.getLogger(LoadMapInfoAjax.class);
public t_balance_office_QueryMap() throws HibernateException {
	this.initSession();
}

public Iterator findAll() throws HibernateException {
	this.totalrow =	((Integer) this.session.iterate("select count(*) from t_balance_office").next()).intValue();
	String querystr = "from t_balance_office";
	Query query = this.session.createQuery(querystr);
    this.setQueryPage(query);
	return query.iterate();
}

public List findAllList() throws HibernateException {
	this.totalrow =	((Integer) this.session.iterate("select count(*) from t_balance_office").next()).intValue();
	String querystr = "from t_balance_office";
	Query query = this.session.createQuery(querystr);
    this.setQueryPage(query);
	return query.list();
}

public List findAllByCounty(String parent_code) throws HibernateException {
	this.totalrow =	((Integer) this.session.iterate("select count(*) from t_balance_office where parent_code ='"+parent_code+"'").next()).intValue();
	String querystr = "from t_balance_office  as t where t.parent_code ='"+parent_code+"'";
	Query query = this.session.createQuery(querystr);
    this.setQueryPage(query);
    
   
    
	return query.list();
}

public t_balance_office_Form getByID(String ID) throws HibernateException {
t_balance_office_Form  vo = null;

  //System.out.println("\nt_balance_office_QueryMap getByID:"+ID);
  logger.debug("\nt_balance_office_QueryMap getByID:"+ID);

	this.session.clear();
	try {
		vo =new t_balance_office_Form();
		t_balance_office po=(t_balance_office) this.session.load(t_balance_office.class, new Integer(ID));

  try{
    vo.setId(String.valueOf(po.getId()));
  }catch (Exception e) {
	    e.printStackTrace();
  }
  vo.setName(po.getName());
  vo.setAddress(po.getAddress());
  vo.setParent_code(po.getParent_code());
  vo.setCompany(po.getCompany());
  vo.setCode(po.getCode());
  try{
    vo.setX(String.valueOf((po.getX())));
  }catch (Exception e) {
    	e.printStackTrace();
  }

  try{
    vo.setY(String.valueOf((po.getY())));
  }catch (Exception e) {
    	e.printStackTrace();
  }
	} catch (HibernateException e) {
		//System.out.println("\nERROR in getByID @t_balance_office:" + e);
		logger.debug("\nERROR in getByID @t_balance_office:" + e);
	}
	return vo;
}	

}
//����������
